<template>
  <view>
    <view class=" ">
      <view class="bg_set"></view>
      <GoodsList   :type="2" :isIndex="false"
                 :goodlistData="RecommendGoodList"></GoodsList>
    </view>
  </view>
</template>

<script setup lang="ts">
import GoodsList from "@/components/home/goods/goodsList.vue";

const RecommendGoodList = ref([]) //推荐商品
const {proxy} = getCurrentInstance()
const queryData=ref({
  page: 1,
  size: 50,
})
const total = ref(0)
// 推荐商品

const getRecommendGoods = () => {
  if (total.value > 0 &&total.value <= queryData.value.page * queryData.value.size) {
    return
  }
  let str=''
  if(partitionRef.value){
    str=`&partition=${partitionRef.value}`
  }else{
    str='&is_hot=1'
  }
  proxy.$request({
    url: `api/goods_list_all/0/?page=${queryData.value.page}&size=${queryData.value.size}${str}`,
    method: 'get',
    success(resd) {
      if (resd.errno == 0) {
        if (queryData.value.page == 1) {
          RecommendGoodList.value = resd.data.data

        }else {
          RecommendGoodList.value = [...RecommendGoodList.value, ...resd.data.data]
        }
        total.value = resd.data.total

      }
    }
  })
}
//触底
onReachBottom(()=>{
  queryData.value.page++
  getRecommendGoods()
})
const partitionRef=ref(null)
onLoad((e)=> {
  if(e.setTitle){
    uni.setNavigationBarTitle({
      title: '品牌直销'
    })
    partitionRef.value=1
  }

  getRecommendGoods()
})
</script>


<style scoped lang="scss">
.bg_set {
background-image: url("https://pili-vod.guanxikeji.com/fubao/img/1755336809330.png");
  width: 100vw;
  height: 180rpx;
}

</style>
